package org.boot.fast.mapp;

import java.util.HashMap;
import java.util.Map;

/* MIME 映射工具类（也可直接用 JDK 的 Files.probeContentType） */
public class MimeMapping {

    private static final Map<String, String> FILE_MIME_MAP = new HashMap<>();

    static {
        FILE_MIME_MAP.put("jpg", "image/jpeg");
        FILE_MIME_MAP.put("jpeg", "image/jpeg");
        FILE_MIME_MAP.put("png", "image/png");
        FILE_MIME_MAP.put("gif", "image/gif");
        FILE_MIME_MAP.put("pdf", "application/pdf");
        FILE_MIME_MAP.put("txt", "text/plain");
        FILE_MIME_MAP.put("html", "text/html");
        FILE_MIME_MAP.put("htm", "text/html");
        FILE_MIME_MAP.put("xml", "text/xml");
        FILE_MIME_MAP.put("json", "application/json");
        FILE_MIME_MAP.put("js", "application/javascript");
        FILE_MIME_MAP.put("css", "text/css");
        FILE_MIME_MAP.put("mp4", "video/mp4");
        FILE_MIME_MAP.put("mp3", "audio/mpeg");
        FILE_MIME_MAP.put("doc", "application/msword");
        FILE_MIME_MAP.put("docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
        FILE_MIME_MAP.put("xls", "application/vnd.ms-excel");
        FILE_MIME_MAP.put("xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        FILE_MIME_MAP.put("ppt", "application/vnd.ms-powerpoint");
        FILE_MIME_MAP.put("pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation");
    }

    public static String getMimeType(String ext) {
        return FILE_MIME_MAP.get(ext);
    }

}